﻿using System.Web.UI;
using Medianamik.Client.Data;
using Medianamik.Core;
using Medianamik.Core.DAL.Repositories;
using Medianamik.UI.Web.Shop.Data.Repositories;
using Medianamik.UI.Web.MVP.Presentation;

namespace Medianamik.UI.Web.Shop.Presentation.Presenters
{
    public class RegionAndTaxeListPresenter<T, TView> : ModulePresenterWithGrid<T, TView,
        IRegionAndTaxRepository<T>, INodeTypeRepository, IMedianamikRepository<IMedianamikDTOWithName>>
        where T : class, IMedianamikDTOWithName
        where TView : class, IRegionAndTaxes
    {
        public RegionAndTaxeListPresenter(TView view, IRegionAndTaxRepository<T> regionAndTaxRepository,
            INodeTypeRepository nodeTypeRepository, IMedianamikRepository<IMedianamikDTOWithName> baseTypeRepository)
            : base(view, regionAndTaxRepository, nodeTypeRepository, baseTypeRepository)
        {

        }

       protected override void SetNameColumn(ITextControl nameGridItem, T element, bool existInCurrentCulture, int childCount)
        {
            if (element.TypeId == TypeIds.Region)
            {
                base.SetNameColumn(nameGridItem, element, existInCurrentCulture, childCount);
                nameGridItem.Text = "<a href=\"" + BuildUrl(Pages.RegionAndTaxList, DefaultParamNames.ParentNodeID,
                        element.NodeId) + "\">" + nameGridItem.Text + "</a>" + FormatChildItemsCount(childCount);
            }
            else
            {
                base.SetNameColumn(nameGridItem, element, existInCurrentCulture, childCount);
            }
        }
    }

     public class RegionAndTaxeListPresenter:RegionAndTaxeListPresenter<BaseType, IRegionAndTaxes>
     {
         public RegionAndTaxeListPresenter(IRegionAndTaxes view, IRegionAndTaxRepository<BaseType> regionAndTaxRepository, INodeTypeRepository nodeTypeRepository, IMedianamikRepository<IMedianamikDTOWithName> baseTypeRepository) : base(view, regionAndTaxRepository, nodeTypeRepository, baseTypeRepository)
         {
         }
     }
}
